package com.example.moblie203zlw0413;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class tiaozhuan2 extends AppCompatActivity {
AlertDialog dialog;
String string[]=new String[]{"默认","小号","中号","大号"};
int i[]={16,26,36,56};
int x=0;
    private TextView textView2;
    private Button button3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tiaozhuan2);
        initView();
    }

    private void initView() {
        textView2 = (TextView) findViewById(R.id.textView2);
        button3 = (Button) findViewById(R.id.button3);
        button3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(tiaozhuan2.this);
                builder.setIcon(R.mipmap.ic_launcher);
                builder.setTitle("设置字体大小");
                builder.setSingleChoiceItems(string, x, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        x=which;
                    }
                });
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                         textView2.setTextSize(i[x]);
                           dialog.dismiss();
                    }
                });
                builder.setNegativeButton("返回", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tiaozhuan2.this.finish();
                        dialog.dismiss();
                    }
                });
                dialog=builder.create();
                dialog=builder.show();
            }
        });
    }
}